﻿//-----------------------------------------------------------------------
// <copyright file="MethodBaseDataContract.cs" company="CodePlex">
//     Copyright (c) Doug Holland, CodePlex. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace CodePlex.Diagnostics.Contracts
{
    using System;
    using System.Collections;
    using System.Reflection;

    using System.Runtime.Serialization;

    /// <summary>
    /// Provides information about methods and constructors. 
    /// </summary>
    [DataContract]
    public sealed class MethodBaseDataContract : IExtensibleDataObject
    {
        #region public MethodBaseDataContract()

        /// <summary>
        /// Initializes a new instance of the <see cref="T:MethodBaseDataContract"/> class.
        /// </summary>
        public MethodBaseDataContract()
        {
        }

        #endregion

        #region public MethodBaseDataContract(MethodBase methodBase)

        /// <summary>
        /// Initializes a new instance of the <see cref="T:MethodBaseDataContract"/> class.
        /// </summary>
        public MethodBaseDataContract(MethodBase methodBase)
        {
            this.IsAbstract = methodBase.IsAbstract;

            this.IsAssembly = methodBase.IsAssembly;

            this.IsConstructor = methodBase.IsConstructor;

            this.IsFamily = methodBase.IsFamily;

            this.IsFamilyAndAssembly = methodBase.IsFamilyAndAssembly;

            this.IsFamilyOrAssembly = methodBase.IsFamilyOrAssembly;

            this.IsFinal = methodBase.IsFinal;

            this.IsGenericMethod = methodBase.IsGenericMethod;

            this.IsGenericMethodDefinition = methodBase.IsGenericMethodDefinition;

            this.IsHideBySignature = methodBase.IsHideBySig;

            this.IsPrivate = methodBase.IsPrivate;

            this.IsPublic = methodBase.IsPublic;
        }

        #endregion

        #region public bool IsAbstract

        /// <summary>
        /// Gets a value indicating whether the method is abstract.
        /// </summary>
        /// <value>A value indicating whether the method is abstract.</value>
        [DataMember]
        public bool IsAbstract
        {
            get;
            set;
        }

        #endregion

        #region public bool IsAssembly

        /// <summary>
        /// Gets a value indicating whether the potential visibility of this method or constructor is described by <see cref="M:MethodAttributes.Assembly"/>; that is, the method or constructor is visible at most to other types in the same assembly, and is not visible to derived types outside the assembly.
        /// </summary>
        /// <value>A value indicating whether the potential visibility of this method or constructor is described by <see cref="M:MethodAttributes.Assembly"/>; that is, the method or constructor is visible at most to other types in the same assembly, and is not visible to derived types outside the assembly.</value>
        [DataMember]
        public bool IsAssembly
        {
            get;
            set;
        }

        #endregion

        #region public bool IsConstructor

        /// <summary>
        /// Gets a value indicating whether the method is a constructor.
        /// </summary>
        /// <value>A value indicating whether the method is a constructor.</value>
        [DataMember]
        public bool IsConstructor
        {
            get;
            set;
        }

        #endregion

        #region public bool IsFamily

        /// <summary>
        /// Gets a value indicating whether the visibility of this method or constructor is described by <see cref="M:MethodAtrributes.Family"/>; that is, the method or constructor is visible only within its class and derived classes.
        /// </summary>
        /// <value>A value indicating whether the visibility of this method or constructor is described by <see cref="M:MethodAtrributes.Family"/>; that is, the method or constructor is visible only within its class and derived classes.</value>
        [DataMember]
        public bool IsFamily
        {
            get;
            set;
        }

        #endregion

        #region public bool IsFamilyAndAssembly

        /// <summary>
        /// Gets a value indicating whether the visibility of this method or constructor is described by <see cref="M:MethodAttributes.FamANDAssem"/>; that is, the method or constructor can be called by derived classes, but only if they are in the same assembly.
        /// </summary>
        /// <value>A value indicating whether the visibility of this method or constructor is described by <see cref="M:MethodAttributes.FamANDAssem"/>; that is, the method or constructor can be called by derived classes, but only if they are in the same assembly.</value>
        [DataMember]
        public bool IsFamilyAndAssembly
        {
            get;
            set;
        }

        #endregion

        #region public bool IsFamilyOrAssembly

        /// <summary>
        /// Gets a value indicating whether the potential visibility of this method or constructor is described by <see cref="M:MethodAttributes.FamORAssem"/>; that is, the method or constructor can be called by derived classes wherever they are, and by classes in the same assembly.
        /// </summary>
        /// <value>A value indicating whether the potential visibility of this method or constructor is described by <see cref="M:MethodAttributes.FamORAssem"/>; that is, the method or constructor can be called by derived classes wherever they are, and by classes in the same assembly..</value>
        [DataMember]
        public bool IsFamilyOrAssembly
        {
            get;
            set;
        }

        #endregion

        #region public bool IsFinal

        /// <summary>
        /// Gets a value indicating whether this method is final.
        /// </summary>
        /// <value>A value indicating whether this method is final.</value>
        [DataMember]
        public bool IsFinal
        {
            get;
            set;
        }

        #endregion

        #region public bool IsGenericMethod

        /// <summary>
        /// Gets a value indicating whether the method is generic.
        /// </summary>
        /// <value>A value indicating whether the method is generic.</value>
        [DataMember]
        public bool IsGenericMethod
        {
            get;
            set;
        }

        #endregion

        #region public bool IsGenericMethodDefinition

        /// <summary>
        /// Gets a value indicating whether the method is a generic method definition.
        /// </summary>
        /// <value>A value indicating whether the method is a generic method definition.</value>
        [DataMember]
        public bool IsGenericMethodDefinition
        {
            get;
            set;
        }

        #endregion

        #region public bool IsHideBySignature

        /// <summary>
        /// Gets a value indicating whether only a member of the same kind with exactly the same signature is hidden in the derived class.
        /// </summary>
        /// <value>A value indicating whether only a member of the same kind with exactly the same signature is hidden in the derived class.</value>
        [DataMember]
        public bool IsHideBySignature
        {
            get;
            set;
        }

        #endregion

        #region public bool IsPrivate

        /// <summary>
        /// Gets a value indicating whether this member is private
        /// </summary>
        /// <value>A value indicating whether this member is private</value>
        [DataMember]
        public bool IsPrivate
        {
            get;
            set;
        }

        #endregion

        #region public bool IsPublic

        /// <summary>
        /// Gets a value indicating whether this is a public method.
        /// </summary>
        /// <value>A value indicating whether this is a public method.</value>
        [DataMember]
        public bool IsPublic
        {
            get;
            set;
        }

        #endregion

        #region public bool IsSpecialName

        /// <summary>
        /// Gets a value indicating whether this method has a special name.
        /// </summary>
        /// <value>A value indicating whether this method has a special name.</value>
        [DataMember]
        public bool IsSpecialName
        {
            get;
            set;
        }

        #endregion

        #region public bool IsStatic

        /// <summary>
        /// Gets a value indicating whether the method is static.
        /// </summary>
        /// <value>A value indicating whether the method is static.</value>
        [DataMember]
        public bool IsStatic
        {
            get;
            set;
        }

        #endregion

        #region public bool IsVirtual

        /// <summary>
        /// Gets a value indicating whether the method is virtual.
        /// </summary>
        /// <value>A value indicating whether the method is virtual.</value>
        [DataMember]
        public bool IsVirtual
        {
            get;
            set;
        }

        #endregion

        #region ExtensionDataObject IExtensibleDataObject.ExtensionData

        /// <summary>
        /// Gets or sets the structure that contains extra data.
        /// </summary>
        /// <value>An <see cref="T:System.Runtime.Serialization.ExtensionDataObject"/> that contains data that is not recognized as belonging to the data contract.</value>
        ExtensionDataObject IExtensibleDataObject.ExtensionData
        {
            get;
            set;
        }

        #endregion
    }
}
